FROM ubuntu:16.04
LABEL maintainer="debin.zhu@eurlanda.com"
LABEL name="deeplabs/vncbase"
LABEL description="Ubuntu 16.04 with VNC and noVNC"
LABEL release-date="2018-04-17"
LABEL version="4.1"

ENV HOME=/root
WORKDIR $HOME

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update -y

RUN apt-get install -y net-tools locales 

RUN apt-get install -y python-numpy

RUN apt-get install -y xfce4 xfce4-goodies
RUN apt-get purge -y pm-utils xscreensaver*

RUN apt-get install -y libxtst-dev libssl-dev libjpeg-dev
RUN apt-get install -y build-essential
ADD x11vnc-0.9.14-dev.tar.gz /opt/
RUN  cd /opt/x11vnc-0.9.14 && ls ./ && \
    ./configure --prefix=/usr/local CFLAGS='-O2 -fno-stack-protector -Wall' && \
    make && \
    make install
#RUN apt-get -y remove libxtst-dev libssl-dev libjpeg-dev build-essential && \
#    apt-get -y autoremove && \
#    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /opt/x11vnc-0.9.14

RUN apt-get install -y language-pack-zh-hans
RUN echo LANG="zh_CN.UTF-8" >> /etc/environment
RUN echo LANGUAGE="zh_CN:zh:en_US:en" >> /etc/environment
RUN locale-gen
RUN apt-get install -y fonts-droid-fallback ttf-wqy-zenhei ttf-wqy-microhei fonts-arphic-ukai fonts-arphic-uming
ENV LANG='zh_CN.UTF-8' LANGUAGE='zh_CN:zh:en_US:en' LC_ALL='zh_CN.UTF-8'

ADD ./bin/xfce/ $HOME/

EXPOSE 5900 6901

ADD websockify.tar.gz /usr/lib/

RUN apt-get install -y supervisor
RUN apt-get install -y xvfb

ADD sogoupinyin_2.2.0.0108_amd64.deb /opt/

RUN apt-get install -y fcitx fcitx-frontend-gtk2 fcitx-frontend-gtk3 fcitx-frontend-qt4 libfcitx-qt0 fcitx-libs-qt fcitx-module-kimpanel im-config libopencc1 lsb-release
RUN apt-get install -y unzip zip fcitx-libs libqtwebkit4
RUN dpkg -i /opt/sogoupinyin_2.2.0.0108_amd64.deb

#RUN apt-get install -y supervisor
#RUN apt-get install -y xvfb
#RUN apt-get -y remove libxtst-dev libssl-dev libjpeg-dev build-essential && \
#    apt-get -y autoremove && \
#    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /opt/x11vnc-0.9.14

RUN mkdir -p /root/.config/autostart && cp /usr/share/fcitx/xdg/autostart/fcitx-autostart.desktop ~/.config/autostart/

ADD hinfs.desktop /root/.config/autostart/

ADD ./bin/install-chrome.sh /opt/
RUN sh /opt/install-chrome.sh

ADD initVNC.sh /usr/local/bin/
ADD supervisord.conf /usr/local/bin/

CMD ["/usr/local/bin/initVNC.sh"]
